<template>
    <div class="culturePlanTemplate system-notice" style="padding-left:10px;">
        <el-row>
            <el-col>
                <div class="item-group">
                    <label class="secondary-text label">审批类型：</label>
                    <div class="display-inline-block">
                        <span class="majoy-text span">信息公告发布</span>
                    </div>
                </div>
            </el-col>
        </el-row>
        <el-row>
            <el-col>
                <div class="item-group">
                    <label class="secondary-text label">审批内容：</label>
                    <div class="display-inline-block">
                        <span class="majoy-text span" style="text-decoration:underline;cursor:pointer"  @click="noticeDetails(content.id)">{{content.title}}
                        </span>
                    </div>
                </div>
            </el-col>
        </el-row>
        <!--信息公告发布-->
        <edu-dialog
            width="1000px"
            class="systemDialog"
            @confirm="confirmMsg"
            confirmBtnText="确定"
            :isCustomTitle="true"
            :showCancelBtn=false
            :autoHeight=false
            :visible.sync="showDetail">
            <span slot="title">
                <img class="title-img" src="/static/images/icon/icon_title.png" /><span class="title-span">{{systemNoticeDetails.title}}</span>
            </span>
            <div class="info">
                <div class="info-date">{{$t('workbench.releaseDate')}}{{systemNoticeDetails.startTime}}</div>
                <div class="info-content" v-html="systemNoticeDetails.content"></div>
                <div class="info-attach">
                    <div v-for="(attach,index) in systemNoticeDetails.commonAttachmentList" :key="index">
                        <div class="attach-item" v-if="attach.fileName" @click="handleDownloadfile(attach.fileLacation, attach.fileName)">
                            <i class="el-icon-document"></i>
                            <span class="attach-name">{{attach.fileName}}</span>
                        </div>
                    </div>
                </div>
            </div>
        </edu-dialog>
    </div>
</template>
<script>
import { getPublicMsgDetail } from "common/src/api/public/information"
import { downloadfile } from "common/src/api/upload"

export default {
    props: {
        content: {
            default: null
        }
    },
    data(){
        return {
            showDetail: false,
            systemNoticeDetails: ''
        }
    },
    methods: {
        // 信息公告发布
        noticeDetails(id) {
            getPublicMsgDetail(id).then(res => {
                if (res && res.data) {
                    this.systemNoticeDetails = res.data;
                    this.systemNoticeDetails.startTime = this.systemNoticeDetails.startTime.slice(0, 10).replace(/-/g, '/');
                    // 显示查看信息
                    this.showDetail = true;
                }
            });
        },
        // 处理下载文件
        handleDownloadfile(objectkey, filename) {
          if (!objectkey) return;
          downloadfile(filename ? objectkey + `&realName=${filename}` : objectkey);
        },
        confirmMsg() {
            this.showDetail = false;
        }
    } 
}
</script>
<style lang="scss" scoped>
  .system-notice {
    // padding: 24px;
    height: 100%;
    overflow: hidden;
    .title {
      font-size: 18px;
      color: #2B3B4E;
      letter-spacing: 0;
      line-height: 24px;
      font-weight: bolder;
      margin: 0;
      img {
        width: 24px;
        height: 24px;
        vertical-align: middle;
      }
      span {
        vertical-align: middle;
      }
      .more-link {
        float: right;
        font-size: 14px;
        color: #3A7FE8;
        span {
          vertical-align: middle;
        }
        img {
          width: 12px;
          height: 12px;
          vertical-align: middle;
        }
      }
    }
    .announcement-list {
      margin-top: 4px;
      height: calc(100% - 28px);
      &.announcement-list-height{
        margin-top: 16px;
        height: calc(100% - 40px);
      }
      ul {
        height: 100%;
      }
      ul, li {
        list-style: none;
        margin: 0;
        padding: 0;
      }
      &::-webkit-scrollbar {/*滚动条整体样式*/
        width: 6px;
        height: 1px;
      }
      &::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
        border-radius: 3px;
        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        background: #D4D8DC;
      }
      &::-webkit-scrollbar-track {/*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        border-radius: 10px;
        background: #fff;
      }
      .announcement-info {
        height: 36px;
        line-height: 36px;
        font-size: 14px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        &.li-announcement-info {
          height: calc(100% / 7);
          line-height: 100%;
        }
        &:hover {
          color: #3A7FE8;
          cursor: pointer;
          .order-wrapper {
            color: #FFFFFF;
            background: #3A7FE8;
          }
          .date {
            color: #3A7FE8;
          }
        }
        &:first-child, &:nth-child(2), &:nth-child(3) {
          .order-wrapper {
            color: #FFFFFF;
            background: #3A7FE8;
          }
        }
        .order-wrapper {
          display: inline-block;
          width: 16px;
          height: 16px;
          line-height: 16px;
          font-size: 12px;
          text-align: center;
          border-radius: 50%;
          color: #2A3B4F;
          background: #E5E9EF;
          margin-right: 8px;
        }
        .topping {
          margin-right: 4px;
          width: 16px;
          height: 16px;
          vertical-align: middle;
        }
          // @media (min-width: 1920px) {
          //   height: 36px;
          //   line-height: 36px;
          //   .topping {
          //       height: 36px;
          //       line-height: 36px;
          //       img {
          //         margin: 10px 0;
          //       }
          //     }
          // }
        .info-content {
          // display: inline-block;
          flex: 1;
          vertical-align: middle;
          padding-right: 50px;
          // width: 400px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .date {
          // float: right;
          color: #8896A7;
        }
      }
    }
    .title-img {
      width: 24px;
      height: 24px;
      vertical-align: middle;
    }
    .title-span {
      margin-left: 8px;
      font-size: 18px;
      color: #2B3B4E;
      vertical-align: middle;
    }
    .info {
      .info-content {
        margin-top: 15px;
        max-width: 100%;
      }
      .info-attach {
          padding: 10px 0;
          .attach-item {
              display: inline-block;
              padding: 3px 0;
              .attach-name {
                  margin-left: 5px;
                  cursor: pointer;
              }
              &:hover {
                  .attach-name {
                      color: #409eff;
                  }
              }
          }
      }
    }
  }
</style>
<style lang="scss">
.system-notice {
  .el-dialog {
    height: 600px;
    overflow: hidden;
    .el-dialog__body {
      max-height: 462px;
      overflow: auto;
    }
  }
}
.system-notice .systemDialog .el-dialog {
  height: unset;
}
</style>